package com.webchat.ugc.service;


import com.webchat.domain.dto.payment.PaymentResultDTO;
import com.webchat.ugc.service.callback.payment.AbstractPaymentCallback;
import com.webchat.ugc.service.callback.payment.PaymentCallbackFactory;
import org.springframework.stereotype.Service;

@Service
public class CallBackService {


    /**
     * 处理支付回调
     *
     * @return
     */
    public boolean doHandlePaymentCallback(PaymentResultDTO callBackRequestBody) {

        /**
         * 基于抽象工厂模式，实现根据回调业务事件，动态回调对应的服务。（高扩展）
         */
        String businessAction = callBackRequestBody.getData().getBusinessAction();
        AbstractPaymentCallback paymentCallback = PaymentCallbackFactory.getService(businessAction);
        return paymentCallback.doCallback(callBackRequestBody);
    }
}
